#include<stdio.h>
int left(int p,int q)
{
    return p+1==q||(p==4&&q==0);
}
int right(int p,int q)
{
    return left(q,p);
}
int near(int p,int q)
{
    return left(p,q)||right(p,q);
}
int main()
{
    int zhao,qian,sun,li,zhou;
    //for(zhao=0;zhao<=4;zhao++)
    zhao=0;
    for(qian=0;qian<=4;qian++)
    for(sun=0;sun<=4;sun++)
    for(li=0;li<=4;li++)
    for(zhou=0;zhou<=4;zhou++)
    {
        if(zhao==qian||zhao==sun||zhao==li||zhao==zhou
           ||qian==sun||qian==li||qian==zhou
           ||sun==li||sun==zhou
           ||li==zhou)continue;
        int zp=near(zhao,qian),zq=left(sun,qian)||left(li,qian);
        int lp=left(qian,sun),lq=near(li,sun);
        if(zp+zq+lp+lq==0)
        {
            printf("%d %d %d %d %d\n", zhao,qian,sun,li,zhou);
        }
    }

}
